#include <boost/test/unit_test.hpp>

#include "flight.h"

using namespace std;
using namespace aviation;

BOOST_AUTO_TEST_CASE(TestFlightDefaultConstructor)
{
	// Constructs an object with an appropriate string 
	Flight flight1;

	BOOST_REQUIRE(flight1.AsString()== "AA001 01012012 0915 AAA AAA 200 20");
}

BOOST_AUTO_TEST_CASE(TestFlightCopyConstructor)
{
	// Copies the flight number from another.
	Flight flight1("AB123 01012012 0915 AAC DAA 200 20");
	Flight flight2(flight1);

	BOOST_REQUIRE(flight1.AsString() == flight2.AsString());

}

BOOST_AUTO_TEST_CASE(TestFlightFCGStringConstructor)
{
	///flight testing
	// A flight with good input
	Flight flight1(string("AB123 01012012 1022 ANC CDA 500 50"));
	// Check correct output
	BOOST_REQUIRE(flight1.AsString() == "AB123 01012012 1022 ANC CDA 500 50");
	//test with lots of spaces 
	Flight flight2(string("AB002           01012012    1022    ABC    CDA 500     50"));
	// Check it's truncated properly.
	BOOST_REQUIRE(flight2.AsString() == "AB002 01012012 1022 ABC CDA 500 50");
	
	//ERRORS!! Each one should cause an exception (error message) to be thrown,

	// Try input with too many details.
	BOOST_CHECK_THROW(Flight(string("AB123 01012012 1022 ABC CDA AAA 500 49 29")), exception);
	///too few details
	//missing Standard Maxseats
	BOOST_CHECK_THROW(Flight(string("AB123   01012012 1022 ABC CDA 50")), exception);
	//missing First Maxseats
	BOOST_CHECK_THROW(Flight(string("AB123   01012012 1022 ABC CDA 500")), exception);
	//Missing date
	BOOST_CHECK_THROW(Flight(string("AB123      1022 ABC CDA 200 20")), exception);
	//missing Flightnumber
	BOOST_CHECK_THROW(Flight(string("   01012012 1022 ABC CDA 500 50")), exception);
	//missing time
	BOOST_CHECK_THROW(Flight(string("AB123 01012012 ABC CDA 500 50")), exception);
	//missing source
	BOOST_CHECK_THROW(Flight(string("AB123 01012012 1022  CDA 200 20")), exception);
	//missing destination
	BOOST_CHECK_THROW(Flight(string("AB123    01012012 1022 ABC 300 30")), exception);

	BOOST_CHECK_THROW(Flight(string("")), std::exception);
    //invalid maxseat number = 1050
	BOOST_CHECK_THROW(Flight(string("AB123 12252015 1022 ABC CDA 2000 2000")), exception);
     //invalid maxseat number = 0
	BOOST_CHECK_THROW(Flight(string("AB123 12252015 1022 ABC CDA 0 0")), exception);	
}

BOOST_AUTO_TEST_CASE(TestFlightAssignmentOperator)
{
	// Assignment operator, copies from 'other'
	Flight flight1("AB123 01012012 1022 ANC CDA 500 50");
	Flight flight2;
	flight2 = flight1;

	BOOST_REQUIRE(flight1.AsString() == flight2.AsString());
}

BOOST_AUTO_TEST_CASE(TestFlightComparisonEqualOperator)
{
	//Returns true if they are the same, or false if they arent
	Flight flight1(string("AB123 01012012 1022 ANC CDA 500 50"));
	Flight flight2(string("AB123 01012012 1022 ANC CDA 500 50"));

	BOOST_REQUIRE(flight1 == flight2);
}

BOOST_AUTO_TEST_CASE(TestFlightComparisonNotEqualoperator)
{
	//Returns true if they are not the same, or false if they are
	Flight flight1(string("AB123 01012012 1022 ANC CDA 500 50"));
	Flight flight2(string("AB123 01012012 1022 AND CDA 500 50"));

	BOOST_REQUIRE(flight1 != flight2);
}

BOOST_AUTO_TEST_CASE(TestFlightComparisonLessthanoperator)
{
	//Returns true if they are not the same, or false if they are
	Flight flight1(string("AB123 01012012 1022 ANC CDA 500 50"));
	Flight flight2(string("AB123 01012012 1022 ANC CDA 800 50"));

	BOOST_REQUIRE(flight1 < flight2);

}

BOOST_AUTO_TEST_CASE(TestGetFlightNumber)
{
	//return the FlightNumber
    Flight flight1(string("AB123 01012012 1022 ANC CDA 500 50"));

	BOOST_REQUIRE(flight1.GetFlightNumber().AsString() == "AB123");
}

BOOST_AUTO_TEST_CASE(TestGetDate)
{
	//return the date
    Flight flight1(string("AB123 10102014 1022 ANC CDA 500 50"));

	BOOST_REQUIRE(flight1.GetDate().AsString() == "10102014");

}

BOOST_AUTO_TEST_CASE(TestGetTime)
{
	//return the time
    Flight flight1(string("AB123 01012012 1022 ANC CDA 500 50"));

	BOOST_REQUIRE(flight1.GetTime().AsString() == "1022");

}

BOOST_AUTO_TEST_CASE(TestGetSource)
{
	//return the Source
    Flight flight1(string("AB123 01012012 1022 ANC CDA 500 50"));

	BOOST_REQUIRE(flight1.GetSource().AsString() == "ANC");

}

BOOST_AUTO_TEST_CASE(TestGetDestination)
{
	//return the Destination
    Flight flight1(string("AB123 01012012 1022 ANC CDA 500 50"));

	BOOST_REQUIRE(flight1.GetDestination().AsString() == "CDA");

}

BOOST_AUTO_TEST_CASE(TestGetMaxStandardSeats)
{
	//return the maxseats in standard class.
    Flight flight1(string("AB123 01012012 1022 ANC CDA 500 50"));

	BOOST_REQUIRE(flight1.GetMaxStandardSeats() == 500);

}

BOOST_AUTO_TEST_CASE(TestGetMaxFirstSeats)
{
	//return the maxseats in first class.
    Flight flight1(string("AB123 01012012 1022 ANC CDA 500 50"));

	BOOST_REQUIRE(flight1.GetMaxFirstSeats() == 50);

}

BOOST_AUTO_TEST_CASE(TestGetFlightID)
{
	//Returns flight ID
	Flight flight1(string("AB123 01012012 1022 ABC CDA 500 50"));
	Flight flight2(string("AB123 01012012 1022 ABC CDA 500 50"));

	BOOST_REQUIRE(flight1.GetID() == flight2.GetID());
}

BOOST_AUTO_TEST_CASE(TestFlightAsString)
{
	//return the Flight AsString as a string
    Flight flight1(string("AB123 01012012 1022 ANC CDA 500 50"));

	BOOST_REQUIRE(flight1.AsString() == "AB123 01012012 1022 ANC CDA 500 50");
}